﻿using AutoFacPack;
using Models;
using RepositoryService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Service
{
    public class ConnectionEntityService : IService
    {
        private ConnectionEntityPepository ConnectionEntityPepository { get; set; }

        public async Task<int> AddConnectionEntity(DbConnectionEntity connectionEntity) 
        {
            connectionEntity.Id = await GetMaxId();
            connectionEntity.Id++;
            return ConnectionEntityPepository.InsertReturnIdentity(connectionEntity);
        }
        public async Task<List<DbConnectionEntity>> GetAllDbConnectionEntity()
        {
            return ConnectionEntityPepository.GetList();
        }

        public async Task<int> GetMaxId() 
        {
            return await ConnectionEntityPepository.GetMaxId();
        }
    }
}
